/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * Projects
 * Copyright (C) Arnaud Duval 2010 <arnaud.duval@gmail.com>
 * 
 * Projects is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Projects is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


#include <DateTime.hpp>


int main (int argc, char *argv[])
{
    ///@brief Testing default constructor
    DateTime defaultDate;
    ///@brief Testing constructor with arguments
    DateTime myBirthDate(1982,9,20,14,30,18);
    ///@brief Testing = operator
    DateTime copiedDateTime;
    copiedDateTime = myBirthDate;
    ///@brief Testing AsString method
    if(myBirthDate.AsString("yyyy-mm-dd--hh:nn:ss") != "1982-09-20--14:30:18")
        return 1;
    if(copiedDateTime.AsString("yyyy-mm-dd--hh:nn:ss") != "1982-09-20--14:30:18")
        return 1;
    if(defaultDate.AsString("yyyy-mm-dd--hh:nn:ss") != "1970-01-01--00:00:00")
        return 1;
    ///@todo More critical tests could be done
    
    ///@brief Testing SetWithFormat method
    DateTime formattedDate;
    formattedDate.SetWithFormat("20/09/1982 à 08:30:57", "dd/mm/yyyy à hh:nn:ss");
    if(formattedDate.AsString("yyyy-mm-dd--hh:nn:ss") != "1982-09-20--08:30:57")
        return 1;
    
    ///@brief Testing NumberOfDays method
    DateTime date1(1982,9,20,14,30,28);
    DateTime date2(1982,9,26,19,20,54);
    if(date2.NumberOfDays() - date1.NumberOfDays() != 6)
        return 1;


    ///@brief Testing IsBissextile methode
    if(myBirthDate.IsBissextile())
        return 1;
    DateTime bissextileDate(1972,12,12,12,12,12);
    if(!bissextileDate.IsBissextile())
        return 1;
    DateTime anotherBissextileDate(2000,02,10,10,10,10);
    if(!anotherBissextileDate.IsBissextile())
        return 1;

    ///@brief Testing NumberOfDaysInTheMonth method
    if(bissextileDate.NumberOfDaysInTheMonth() != 31)
        return 1;
    if(myBirthDate.NumberOfDaysInTheMonth() != 30)
        return 1;
    if(anotherBissextileDate.NumberOfDaysInTheMonth() != 29)
        return 1;
    
    ///@brief Testing Normalize method and setters
    DateTime normDate;
    normDate.SetYear(1982);
    normDate.SetMonth(9);
    normDate.SetDay(20);
    normDate.SetHour(18);
    normDate.SetMinute(18);
    normDate.SetSecond(62);
    normDate.Normalize();
    ///@brief Tests normalization when seconds value is greater than 59
    if(normDate.AsString("yyyy-mm-dd--hh:nn:ss") != "1982-09-20--18:19:02")
        return 1;
    normDate.SetMinute(59);
    normDate.SetSecond(78);
    normDate.Normalize();
    ///@brief Tests normalization when second value is greater than 59 and minutes value is 59
    if(normDate.AsString("yyyy-mm-dd--hh:nn:ss") != "1982-09-20--19:00:18")
        return 1;
    
    ///@todo Testing of DateTime class should be completed    
    
    
    

        
    
    return 0;
}
